package com.javabasic.proxy;

import com.javabasic.cglib.UserService1;
import com.javabasic.cglib.UserServiceImp1;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @author: 晓帆
 * @description:
 * @create: 2021-06-24 19:44
 **/
public class JavaProxyDemo {
    static UserService userService = new UserServiceIpm();
    public static void main(String[] args) {
        UserService o = (UserService) Proxy.newProxyInstance(JavaProxyDemo.class.getClassLoader(), UserServiceIpm.class.getInterfaces(), new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                Object invoke = method.invoke(userService, args);
                System.out.println("增强");
                return null;
            }
        });
        o.say2("张三");
    }
}
